package com.example.controller;

import com.alibaba.fastjson.JSON;
import com.example.model.People;
import com.example.model.User;
import com.example.service.MultiDataSourceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 多数据源测试入口
 */
@Slf4j
@RestController
public class MultiDataSourceController {

	@Resource
	private MultiDataSourceService multiDataSourceService;

	@PostMapping("/testMultiDsGetUser")
	public String testMultiDsGetUser() {

		List<User> userList = multiDataSourceService.listUser();
		log.info("userList:{}", JSON.toJSONString(userList));

		List<People> peopleList = multiDataSourceService.listPeople();
		log.info("peopleList:{}", JSON.toJSONString(peopleList));

		return "userSize: "+userList.size()+" peopleSize: "+peopleList.size();

	}

}
